<!-- 遍历标签,for,list,dict示例 -->
{layout file="base.html"}
<body>
<!-- 通用遍历,兼容list,dict -->
{for name="users" index="index" value="user"}
    <div>{user['userid']}</div>
    <div>{user['realName']}</div>
    <div>{:user['realName']|safe}</div>
{/for}


<!-- 非属性遍历,原始python 格式 -->
{for user in users}
    <div>{user['userid']}</div>
    <div>{user['realName']}</div>
    <div>{:user['realName']|safe}</div>
{/for}


<!-- 遍历list -->
{list name="users" index="index" key="key" value="user"}
    <div>自定义序号(默认为0):{index}</div>
    <div>list本身的序号:{key}</div>
    <div>{user['userid']}</div>
    <div>{user['realName']}</div>
    <div>{:user['realName']|safe}</div>
{/list}

<!-- 遍历dict -->
{dict name="stuNames" key="key" value="name"}
    <div>键:{key}</div>
    <div>值:{name}</div>
    <div>安全过滤:{:name|safe}</div>
{/dict}


<!-- 标签格式 -->

<!-- 通用遍历,兼容list,dict -->
<for name="users" index="index" value="user">
    <div>{user['userid']}</div>
    <div>{user['realName']}</div>
    <div>{:user['realName']|safe}</div>
</for>

<!-- 遍历list -->
<list name="users"  value="user">
    <div>{user['userid']}</div>
    <div>{user['realName']}</div>
    <div>{:user['realName']|safe}</div>
</list>

<!-- 遍历dict -->
<dict name="stuNames" key="key" value="name">
    <div>键:{key}</div>
    <div>值:{name}</div>
    <div>安全过滤:{:name|safe}</div>
</dict>

</body>








